package br.com.j7.jdesk.persistence.entity;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;

import br.com.j7.jdesk.persistence.listener.EnterpriseListener;

/**
 * 
 * 
 * @author Edivando Alves
 *
 */
@Entity
@EntityListeners(value={EnterpriseListener.class})
@NamedQueries( {@NamedQuery(name="enterprise", query="Select e from Enterprises e"), 
				@NamedQuery(name="enterpriseByCdEnterprise", query="select e from Enterprises e where e.cdEnterprise = ?1")} )
public class Enterprises implements Serializable{

	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer idEnterprise;

	@Column(nullable=true, length=200)
	private String cdEnterprise;
	
	private String cdCNPJ;
	
	private String cdAddress;
	
	private String cdNeighborhood;
	
	private String cdCity;
	
	private String cdPhone;
	
	private Integer nrVersion;
	
	@OneToMany(mappedBy="enterprise", cascade=CascadeType.PERSIST)
	private List<Customers> customers;
	
	@OneToMany(mappedBy="enterprise", cascade=CascadeType.PERSIST)
	private List<Services> services;
	
	@OneToMany(mappedBy="enterprise", cascade=CascadeType.PERSIST)
	private List<UsersGroups> usersGroups;
	
	@OneToMany(mappedBy="enterprise", cascade=CascadeType.PERSIST)
	private List<ServicesTypes> servicesTypes;
	
	@OneToMany(mappedBy="enterprise", cascade=CascadeType.PERSIST)
	private List<ServicesSituations> servicesSituations;
	
	@OneToMany(mappedBy="enterprise", cascade=CascadeType.PERSIST)
	private List<Products> products;
	
	@OneToMany(mappedBy="enterprise", cascade=CascadeType.PERSIST)
	private List<Products> sales;
	
	
	public Enterprises() {
	}

	public Integer getIdEnterprise() {
		return idEnterprise;
	}

	public void setIdEnterprise(Integer idEnterprise) {
		this.idEnterprise = idEnterprise;
	}

	public String getCdEnterprise() {
		return cdEnterprise;
	}

	public void setCdEnterprise(String cdEnterprise) {
		this.cdEnterprise = cdEnterprise;
	}

	public String getCdCNPJ() {
		return cdCNPJ;
	}

	public void setCdCNPJ(String cdCNPJ) {
		this.cdCNPJ = cdCNPJ;
	}

	public String getCdAddress() {
		return cdAddress;
	}

	public void setCdAddress(String cdAddress) {
		this.cdAddress = cdAddress;
	}

	public String getCdNeighborhood() {
		return cdNeighborhood;
	}

	public void setCdNeighborhood(String cdNeighborhood) {
		this.cdNeighborhood = cdNeighborhood;
	}

	public String getCdCity() {
		return cdCity;
	}

	public void setCdCity(String cdCity) {
		this.cdCity = cdCity;
	}

	public String getCdPhone() {
		return cdPhone;
	}

	public void setCdPhone(String cdPhone) {
		this.cdPhone = cdPhone;
	}

	public List<Customers> getCustomers() {
		return customers;
	}
	
	public void setCustomers(List<Customers> customers) {
		this.customers = customers;
	}
	
	public List<Services> getServices() {
		return services;
	}
	
	public void setServices(List<Services> services) {
		this.services = services;
	}
	
	public List<UsersGroups> getUsersGroups() {
		return usersGroups;
	}
	
	public void setUsersGroups(List<UsersGroups> usersGroups) {
		this.usersGroups = usersGroups;
	}
	
	public List<ServicesTypes> getServicesTypes() {
		return servicesTypes;
	}
	
	public void setServicesTypes(List<ServicesTypes> servicesTypes) {
		this.servicesTypes = servicesTypes;
	}
	
	public List<ServicesSituations> getServicesSituations() {
		return servicesSituations;
	}
	
	public void setServicesSituations(List<ServicesSituations> servicesSituations) {
		this.servicesSituations = servicesSituations;
	}
	
	public List<Products> getProducts() {
		return products;
	}
	
	public void setProducts(List<Products> products) {
		this.products = products;
	}
	
	public List<Products> getSales() {
		return sales;
	}
	
	public void setSales(List<Products> sales) {
		this.sales = sales;
	}
	
	public Integer getNrVersion() {
		return nrVersion;
	}
	
	public void setNrVersion(Integer nrVersion) {
		this.nrVersion = nrVersion;
	}
	
	@Override
	public int hashCode() {
		return idEnterprise;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Enterprises other = (Enterprises) obj;
		if (idEnterprise == null) {
			if (other.idEnterprise != null)
				return false;
		} else if (!idEnterprise.equals(other.idEnterprise))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return cdEnterprise;
	}
	
	
	
}
